<template>
	<basicContainer>
		<avue-crud :option="option" :data="data" :page="page" ref="crud" @search-change="searchChange" @search-reset="searchReset"
		 @current-change="currentChange" @size-change="sizeChange" @on-load="onLoad">
		</avue-crud>
	</basicContainer>
</template>

<script>
	import request from '@/router/axios';
	export default {
		props: {
			boxNum: ''
		},
		data() {
			return {
				query: {},
				page: {
					pageSize: 10,
					currentPage: 1,
					total: 0
				},
				option: {
					searchMenuSpan: 4,
					border: true,
					index: true,
					addBtn: false,
					delBtn:false,
					searchBtn:false,
					columnBtn:false,
					//header:false,
					refreshBtn: false,
					excelBtn: true,
					menu:false,
					showSummary: true,
					sumColumnList: [{
						name: 'quantity',
						type: 'sum'
					}],
					column: [{
							label: "箱号",
							prop: "boxNum",
							width:200
						},
						{
							label: "订单号",
							prop: "orderCode"
						},
						{
							label: "条码",
							prop: "barCode"
						},
						{
							label: "数量",
							prop: "quantity",
							width:60
						}
					]
				},
				data: []
			};
		},
		methods: {
			searchReset() {
				this.query = {};
				this.page.currentPage = 1;
				this.onLoad(this.page);
			},
			currentChange(currentPage) {
				this.page.currentPage = currentPage;
			},
			searchChange(params, done) {
				this.page.currentPage = 1;
				this.query = params;
				this.onLoad(this.page);
				done();
			},
			sizeChange(pageSize) {
				this.page.pageSize = pageSize;
			},
			onLoad(page) {
				request({
					url: '2/api/OrderPkgDetail/pages',
					params: {
						type: this.boxNum == undefined ? '' : this.boxNum,
						page: page.currentPage,
						limit: page.pageSize
					}
				}).then(res => {
						const data = res.data
						this.data = data.data;
						this.page.total = data.remark;
					}
				);
			}
		}
	};
</script>

<style>
</style>
